home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1511 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.2 KB

  1. Path: dialup-4.act.apana.org.au!daedelus
  2. From: Alex Satrapa <daedelus@posgate.apana.org.au>
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.edu,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: 11 Jan 1996 12:23:45 GMT
  6. Organization: -
  7. Distribution: world
  8. Message-ID: <4d2vgh$f5m@posgate.acis.com.au>
  9. References: <LQs1wg2yqf9U083yn@iaccess.za> <dewar.819838019@schonberg> <dewar.819838217@schonberg> <E/56wg2yqXwB083yn@iaccess.za>
  10. NNTP-Posting-Host: dialup-4.act.apana.org.au
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=ISO-8859-1
  13. Content-Transfer-Encoding: 8bit
  14. X-Newsreader: Nuntius 2.0.4_68K
  15. X-XXMessage-ID: <AD1B4B4C90015A85@dialup-4.act.apana.org.au>
  16. X-XXDate: Thu, 11 Jan 1996 06:18:36 GMT
  17.  
  18. In article <E/56wg2yqXwB083yn@iaccess.za> Vince Risi, vincer@iaccess.za
  19. writes:
  20.  
  21. >> >  Branch Branch1 = Branches[First];
  22. >> >  Branch Branch2 = Branches[Second];
  23. >> >  // if the branches are of the same kind...
  24. >> >  // ...and the same destination...
  25. >> >  if (KindBranch(Branch1) == KindBranch(Branch2) &&
  26. >> >      DestBranch(Branch1) == DestBranch(Branch2))
  27. >> >  {
  28. >> >    // do something useful with the parallel edges
  29. >> >    ...
  30. >> >  }
  31.  
  32. I *like* this code! When you read it, it *means* something - look at the
  33. first
  34. line - set (branch-type variable) Branch number 1 to the first branch in
  35. the
  36. array of Branches.
  37.  
  38. Check out the if - if the kind of Branch 1 is the same as the kind of
  39. Branch 2...
  40.  
  41. In Object Pascal this would be more like
  42.  
  43.   Branch1 := Branches[FIRST];
  44.   Branch2 := Branches[SECOND];
  45.   if (Branch1.kind = Branch2.kind) and
  46.        (Branch1.dest = Branch2.dest) then
  47.        begin
  48.            { Do something useful with the *converging* edges }
  49.        end
  50.        
  51. Sometimes in procedural Pascal I'll have variables named Variable,
  52. VariablePtr
  53. and maybe even VariableH - variable, pointer to variable and handle to
  54. variable.
  55.  
  56.  
  57. I saw one guy writing code for Gupta SQL Windows - it was horrible -
  58. everywhere
  59. he'd have stuff like bfBlah and giMoose meaning "background field called
  60. Blah" and
  61. "Global integer called Moose". What made me so distraught was the fact
  62. that
  63. so much of the code was dependent on the *type* of the variable, rather
  64. than
  65. the *content*.
  66.  
  67. As to comments about strings being strings - here are two strings that
  68. are not
  69. really strings:
  70.  
  71.  "[123,234,456,567]"
  72.  
  73. and
  74.  
  75.  "{Cheque,65472,Whistlestop cafe,Fried Green tomatoes,$54.34,12/3/45}"
  76.  
  77. The first represents a list of numbers that could be of any length. While
  78. some
  79. people would like to use pointers, what about storing this arbitrary
  80. length
  81. array in human readable form?
  82.  
  83. The second represents a transaction in a personal accounts system. While a
  84. record could be used, I would once again use this human-readable form to
  85. store it in a text file while I'm testing/debugging my program -
  86. especially
  87. if I'm doing cross-platform development (eg: big/little endian problems, 8
  88. versus 16 bit integers, IEEE versus someone else's reals).
  89.  
  90. In one development cycle, I may prefer to use strings. The next time
  91. round, I
  92. decide to change them all to records (mainly to conserve memory). I don't
  93. want
  94. to change *every variable name* to indicate that the variable is now a
  95. record,
  96. rather than a string.
  97.  
  98. There... I've expressed my thoughts...
  99. -Alex
  100.